package com.liangtian.mdm.dm.jsp.controller;

import com.alibaba.fastjson.JSON;
import com.liangtian.mdm.base.controller.BaseController;
import com.liangtian.mdm.dm.jsp.service.BootstrapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/bootAction")
public class BootstrapActionController extends BaseController {

    @Autowired
    private BootstrapService bootstrapService;

    @RequestMapping(value = "/queryBootSel", method = RequestMethod.POST)
    @ResponseBody
    public String queryBootSel(HttpServletRequest request) {
        //这两种返回类型是需要判断的,如果是关联的别的主数据的类型,返回到页面的应该是code/value形式的,则返回map,如果是类似与"是/否"这种属性则返回一个list
        String code = request.getParameter("code");
        String table = request.getParameter("mTable");
        Map<String, Object> retMap = bootstrapService.queryBootSel(table, code);
        return JSON.toJSONString(retMap);
    }


    public String checkTableValiable(HttpServletRequest request) {

        String tableName = request.getParameter("tableName");
        boolean flag = bootstrapService.checkTableValiable("AM_MODEL");
        System.out.println(flag);
        return null;

    }

    public String getColAndComment(HttpServletRequest request) {

        String tableName = request.getParameter("tableName");
        List<Map<String, String>> l = bootstrapService.getColAndComment("AM_MODEL");
//		System.out.println(flag);
        return null;

    }
}
